public class Foo {
    int x, y;

    public Foo(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public String toString() {
        return "Foo{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }

    public static void swaperoo(Foo a, Foo b) {
        Foo temp = a;
        System.out.println(temp);
        a.x = b.x;
        a.y = b.y;
        System.out.println(temp);

        b.x = temp.x;
        b.y = temp.y;
    }

    public static void main(String[] args) {
        Foo foobar = new Foo(10, 20);
        Foo baz = new Foo(30, 40);
        swaperoo(foobar, baz);
        System.out.println("f==" + foobar);
        System.out.println("b==" + baz);
    }
}
